package com.caltco.cargo.ops.common.autoconfigure;

import com.caltco.cargo.ops.common.utils.AntPathMatcher;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @Title: 白名单/业务模块等配置
 * @Description: TODO
 * @Author: yehao
 * @DateTime: 2023/2/17 8:59
 */
@Configuration
@ConfigurationProperties(prefix = "agilefast")
public class AgileFastConfiguration {

    private List<String> whitelist;
    private List<String> modules;


    protected AntPathMatcher pathMatcher = new AntPathMatcher();

    public List<String> getWhitelist() {
        return whitelist;
    }

    public void setWhitelist(List<String> whitelist) {
        this.whitelist = whitelist;
    }

    public List<String> getModules() {
        return modules;
    }

    public void setModules(List<String> modules) {
        this.modules = modules;
    }

    public boolean isPermitAllUrl(String url) {
        for (String pattern : whitelist) {
            if (pathMatcher.match(pattern, url)) {
                return true;
            }
        }
        return false;
    }
}
